//
//  NNMainTabBarController.swift
//  DYLive
//
//  Created by 众力金融 on 2019/4/30.
//  Copyright © 2019 众力金融. All rights reserved.
//

import UIKit

class NNMainTabBarController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        
        let tabBar = UITabBar.appearance()
        tabBar.tintColor = .orange
        tabBar.backgroundColor = .white
        tabBar.isTranslucent = false
//        UITabBarItem.appearance().setTitleTextAttributes([.foregroundColor : UIColor.orange], for: .selected)
//
//        UITabBarItem.appearance().setTitleTextAttributes([.foregroundColor : UIColor.red], for: .normal)
        
         baseConfig()
    }
    
    func baseConfig() {
        setupChildViewController(childController: NNHomeViewController(), title: "首页", imageName: "btn_home_normal", selectedImageName: "btn_home_selected")
        setupChildViewController(childController: NNLiveViewController(), title: "直播", imageName: "btn_column_normal", selectedImageName: "btn_column_selected")
        setupChildViewController(childController: NNFollowViewController(), title: "关注", imageName: "btn_live_normal", selectedImageName: "btn_live_selected")
        setupChildViewController(childController: NNMeViewController(), title: "我的", imageName: "btn_user_normal", selectedImageName: "btn_user_selected")
        
    }
    
    func setupChildViewController(childController: UIViewController, title: String, imageName: String, selectedImageName: String) {
        
        childController.title = title
        childController.tabBarItem.image = UIImage(named: imageName)
        childController.tabBarItem.selectedImage = UIImage(named: selectedImageName)?.withRenderingMode(UIImage.RenderingMode.alwaysOriginal)
        let nacV = NNNavigationViewController(rootViewController: childController)
        addChild(nacV)
    }
  
}
